package com.xiaotao.util;

import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

@Component
public class RabbitMessageUtil implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnsCallback {
    //不管确认成功或者失败，都会执行此方法
    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String s) {
        if (!ack){
            System.out.println("消息发送失败");
        }
    }



   //
    @Override
    public void returnedMessage(ReturnedMessage returned) {
        System.out.println("消息投送到队列失败");
        //存入mysql

    }
}
